Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When encountering <&T as Clone>::clone(x) because T: Clone, suggest #[derive(Clone)] #121471

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

estebank
Copy link
Contributor

CC #40699.

warning: call to `.clone()` on a reference in this situation does nothing
  --> $DIR/noop-method-call.rs:23:71
   |
LL |     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
   |                                                                       ^^^^^^^^
   |
   = note: the type `PlainType<u32>` does not implement `Clone`, so calling `clone` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed
help: remove this redundant call
   |
LL -     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
LL +     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref;
   |
help: if you meant to clone `PlainType<u32>`, implement `Clone` for it
   |
LL + #[derive(Clone)]
LL | struct PlainType<T>(T);
   |

@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2024

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 22, 2024
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Feb 22, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 22, 2024

📌 Commit 6017de4 has been approved by TaKO8Ki

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 22, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#121434 (Fix rust-lang#121208 fallout)
 - rust-lang#121471 (When encountering `<&T as Clone>::clone(x)` because `T: Clone`, suggest `#[derive(Clone)]`)
 - rust-lang#121476 (remove `llvm.assertions=true` in compiler profile)
 - rust-lang#121479 (fix generalizer unsoundness)
 - rust-lang#121480 (Fix more rust-lang#121208 fallout)
 - rust-lang#121482 (Allow for a missing `adt_def` in `NamePrivacyVisitor`.)
 - rust-lang#121484 (coverage: Use variable name `this` in `CoverageGraph::from_mir`)
 - rust-lang#121487 (Explicitly call `emit_stashed_diagnostics`.)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#121434 (Fix rust-lang#121208 fallout)
 - rust-lang#121471 (When encountering `<&T as Clone>::clone(x)` because `T: Clone`, suggest `#[derive(Clone)]`)
 - rust-lang#121476 (remove `llvm.assertions=true` in compiler profile)
 - rust-lang#121479 (fix generalizer unsoundness)
 - rust-lang#121480 (Fix more rust-lang#121208 fallout)
 - rust-lang#121482 (Allow for a missing `adt_def` in `NamePrivacyVisitor`.)
 - rust-lang#121484 (coverage: Use variable name `this` in `CoverageGraph::from_mir`)
 - rust-lang#121487 (Explicitly call `emit_stashed_diagnostics`.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 86727df into rust-lang:master Feb 23, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2024
Rollup merge of rust-lang#121471 - estebank:lint-clone, r=TaKO8Ki

When encountering `<&T as Clone>::clone(x)` because `T: Clone`, suggest `#[derive(Clone)]`

CC rust-lang#40699.

```
warning: call to `.clone()` on a reference in this situation does nothing
  --> $DIR/noop-method-call.rs:23:71
   |
LL |     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
   |                                                                       ^^^^^^^^
   |
   = note: the type `PlainType<u32>` does not implement `Clone`, so calling `clone` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed
help: remove this redundant call
   |
LL -     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
LL +     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref;
   |
help: if you meant to clone `PlainType<u32>`, implement `Clone` for it
   |
LL + #[derive(Clone)]
LL | struct PlainType<T>(T);
   |
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants